<?php
set_time_limit(0);
include '../config/config.php';

$url='https://pc.qq.com/detail/12/detail_12.html';
include 'dom.php';
$html = file_get_html($url);
$logo=$html->find('div.detail-logo a img',0);
$logoUrl='http://'.substr($logo->src, 2);
$title=$html->find('h2.detail-name',0)->plaintext;
$score=$html->find('div.detail-info span.detail-score',0)->plaintext;



echo $score;

exit;


$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}



 
?>



<?php
exit;
$parseUrl=explode('_', $url);
$flagid=str_replace('.html', '', $parseUrl[count($parseUrl)-1]); 

$html = file_get_html($url);
$ul_Address=$html->find('#download',0);
$script=$ul_Address->innertext;
$downloadLink='';
if(preg_match_all( '/script([\w\W]*)<\/script>/iU', $script, $getScript) ){
    foreach ($getScript[0] as $v){
        if(strpos($v,'_downInfo') !== false &&  strpos($v,'Address') !== false){
            $parseScript=explode('Address', $v);
            $parseScript2=explode(',', $parseScript[1]);
         
            $softLinkId=preg_replace('/"|:|TypeID/', '', $parseScript2[1]);
            $preLink=explode('||', $pc6SoftLink['siteId_'.$softLinkId]);
            $preLink2=explode(',', $preLink[1]);
           
            $downloadLink=$preLink2[0].preg_replace('/"|:/', '', $parseScript2[0]);
 
            break;
        }
        
    }
}

 

$logo=$html->find('#main img',0)->src;
$descripton=str_replace('pc6', '小猪', $html->find('meta[name=description]',0)->content);
$title=$html->find('#softTit h1',0)->plaintext;
$version=$html->find('#softTit span',0)->plaintext;
$content=htmlspecialchars($html->find('.main-info', 0)->innertext);
foreach($html->find('ul.param-ul') as $pcName) {
    $softSize=$pcName->find('li span',0)->plaintext;  //软件大小
    $updateTime=$pcName->find('span.pub-time', 0)->plaintext; //更新日期
    $updateTime=explode('/', $updateTime);
    $updateTime2 = mktime(0, 0, 0, $updateTime[1], $updateTime[2], $updateTime[0]);
    $language=$pcName->find('li span', 2)->plaintext;
    $softLei=$pcName->find('li span', 3)->plaintext;
    $softpower=$pcName->find('li span', 4)->plaintext;
    $website=$pcName->find('li span', 5)->plaintext;
    $platform=$pcName->find('li span', 6)->plaintext;
}

$sql="select aid from ey_archives where flagid='".$flagid."'  limit 0,1 ";
$query = $mysqli->query($sql);
$arInfo=array();

if($query->num_rows>0){
    $arInfo=$query->fetch_assoc();
    $aid=$arInfo['aid'];
    $sql="update ey_archives set
       softsize='".$softSize."',
       update_time='".$updateTime2."',
       language='".$language."',
	   softlei='".$softLei."',
       softpower='".$softpower."',
       website='".$website."',
       platform='".$platform."',
       title='".$title."',
       version='".$version."'
       where aid='".$aid."'
    ";
 
    $mysqli->query($sql);
    $sql="update ey_article_content set
       content='".$content."'
       where aid='".$aid."'
    ";
    $mysqli->query($sql);
}else{
    $sql="insert into ey_archives (downloadlink,logo,seo_description,typeid,channel,title,softsize,update_time,language
       ,softlei,softpower,website,platform,version,flagid) values('".$downloadLink."','".$logo."','".$descripton."','3','1','".$title."','".$softSize."'
       ,'".$updateTime2."','".$language."','".$softLei."','".$softpower."','".$website."','".$platform."','".$version."','".$flagid."')";

    $mysqli->query($sql);
    
    $sql="select aid from ey_archives where flagid='".$flagid."'  limit 0,1 ";
    $query = $mysqli->query($sql);
    $arInfo=$query->fetch_assoc();
    $aid=$arInfo['aid'];
    
    $sql="insert into ey_article_content(aid,content) values('".$aid."','".$content."')";
    $mysqli->query($sql);
}
echo 'done';
$mysqli->close();
exit;
?>
<script>
window.setTimeout(function(){
	   window.location.href="?id=<?php echo ($id+1); ?>";
	}, 1000);
</script>